package sf.dynamicsql;

import org.mybatis.dynamic.sql.delete.DeleteModel;
import org.mybatis.dynamic.sql.insert.GeneralInsertModel;
import org.mybatis.dynamic.sql.insert.InsertSelectModel;
import org.mybatis.dynamic.sql.select.SelectModel;
import org.mybatis.dynamic.sql.update.UpdateModel;
import sf.common.wrapper.Page;

import java.sql.Connection;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.stream.Stream;

public interface DynmicSQLModelInf {
    int insert(Connection conn, List<String> pkeys, Map<String, Object> keyValues, GeneralInsertModel generalInsertModel);

    int insertSelect(Connection conn, List<String> pkeys, Map<String, Object> keyValues, InsertSelectModel insertSelectModel);

    int update(Connection conn, UpdateModel updateModel);

    int delete(Connection conn, DeleteModel deleteModel);

    <T> Page<T> selectPage(Connection conn, long start, int limit, Class<T> beanClass, SelectModel selectModel);

    <T> Page<T> selectPageRaw(Connection conn, long start, int limit, Class<T> beanClass, SelectModel countSelectModel,
                              SelectModel listSelectModel);

    Object[] selectArray(Connection conn, SelectModel selectModel);

    <T> List<T> selectList(Connection conn, Class<T> beanClass, SelectModel selectModel);

    <T> List<T> selectList(Connection conn, Class<T> beanClass, SelectModel selectModel, long start, int limit);

    <T> T selectOne(Connection conn, Class<T> beanClass, SelectModel selectModel);

    List<Map<String, Object>> select(Connection conn, SelectModel selectModel);

    <T> void selectIterator(Connection conn, Consumer<Iterable<T>> ormIt, Class<T> returnClass, SelectModel selectModel);

    <T> void selectStream(Connection conn, Consumer<Stream<T>> ormStream, Class<T> returnClass, SelectModel selectModel);
}
